% script that illustrates how to postprocess the rat heart data
% make sure you set the right base and subdirs for either T1 or T2 analysis
% For questions: Henk Smit h.smit@erasmusmc.nl 
% Use ctrl+enter to execute only the currently yellow part (from %% to %%)

%% Set the base directory where the T1 rats scans are located
basedir2 = 'C:\Users\Henk Smit\Desktop\MRData\111105 T1 Rat Repro Alessandro\10265-10 (erroneusly referred as -15)';

% Fill in the names of the T2 subdirectories, for the consecutive days:
subdirs2 = {
    '1418'
            };

% Fill in the name of the images
file = '0007'; 

%% Make the T1 maps for each day. 
%Choose here which subdir you want to process:
subdir2 = subdirs2{1};
studydir2 = fullfile(basedir2, subdir2);

%Perform fitting 
outdir2 = ratheartT1fit( studydir2, file);

%If you want to redraw regions of interest:
%outdir = ratheartT2fit( studydir, file, true );

%% Select 5 points for each day
%Choose here which subdir you want to process:
subdir2 = subdirs2{4};
studydir2 = fullfile(basedir2, subdir2);
ratheartpointselect( studydir2 );

%% Start registrations; it loops automatically over all subdirs
day1studydir2 = fullfile(basedir2, subdirs2{1} );
for day = 2:numel(subdirs2)
  nextdaystudydir2 = fullfile(basedir2, subdirs2{day} );
  ratheartregister( day1studydir2, nextdaystudydir2 );
end

%% Show the final graphs of the six regions.
outdata = ratheartsegmentation( basedir2, subdirs2 );
% outdata contains some data that you might want to inspect;


%% Select the SPIO and a myocardial region show the graphs
%Results are printed in 'results.txt' in the postproc directory of day 1
% mapcolorrange = [0 1200];
% ratheartdrawallspio ( basedir2, subdirs2, mapcolorrange, true );
%If you want to redraw regions of interest:
%ratheartdrawallspio ( basedir2, subdirs2, mapcolorrange, true );



